<!DOCTYPE html>
<html>
<meta charset="utf-8">
<head th:include="include :: header"></head>
    <style>
        /* reset */
        html,body,h1,h2,h3,h4,h5,h6,div,dl,dt,dd,ul,ol,li,p,blockquote,pre,hr,figure,table,caption,th,td,form,fieldset,legend,input,button,textarea,menu{margin:0;padding:0;}
        header,footer,section,article,aside,nav,hgroup,address,figure,figcaption,menu,details{display:block;}
        table{border-collapse:collapse;border-spacing:0;}
        caption,th{text-align:left;font-weight:normal;}
        html,body,fieldset,img,iframe,abbr{border:0;}
        i,cite,em,var,address,dfn{font-style:normal;}
        [hidefocus],summary{outline:0;}
        li{list-style:none;}
        h1,h2,h3,h4,h5,h6,small{font-size:100%;}
        sup,sub{font-size:83%;}
        pre,code,kbd,samp{font-family:inherit;}
        q:before,q:after{content:none;}
        textarea{overflow:auto;resize:none;}
        label,summary{cursor:default;}
        a,button{cursor:pointer;}
        h1,h2,h3,h4,h5,h6,em,strong,b{font-weight:bold;}
        del,ins,u,s,a,a:hover{text-decoration:none;}
        body,textarea,input,button,select,keygen,legend{font:12px/1.14 arial,\5b8b\4f53;color:#333;outline:0;}
        body{background:#fff;}
        a,a:hover{color:#333;}
        body{
            background: #e4e8f4;
        }
        .normal-input{
            height: 26px;
            line-height: 26px;
        }
        .flex-box{
            display: flex;
            align-items: center;
        }
        .ml{
            margin-left: 10px;
        }
        button{
            padding: 0 5px;
        }
        .item-net{
            background: #70819f;
            width: 35px;
            height: 62px;

        }
        .margin20{
            margin: 20px;
        }
        .item{
            padding:0 10px 10px;

        }
        .item-net{
            display: flex;
            justify-content: space-around;
            flex-direction: column;
            align-items: center;
            float: left;
            margin-left: 8px;
            margin-right:8px;
            cursor: pointer;
            margin-bottom: 20px;
        }
        .num,.box-icon{
            color: #fff;
            font-size: 16px;
        }
        .iconfont{
            font-size: 18px!important;
        }
        .active{
            background: #20ae36;
        }
        .tip-info{
            padding: 20px;
            clear: both;
            text-align: center;
            display: flex;
            justify-content: center;
            align-items: center;
            font-size: 14px;
        }
        .ok,.online,.invalid{
            display: inline-block;
            width: 48px;
            height: 16px;
            background: #7080a1;
            margin-left: 20px;
            margin-right: 5px;
        }
        .online{
            background: #20ae36;
        }
        .invalid{
            background: url();
            background-size: 100%;
        }

        .trips{min-height:22px; line-height:22px; padding:6px;border-radius:4px;}
        .trips .tripscon{font-size:12px;color:#000; float:left; overflow:hidden;}
        .trips .tripsclose{width:12px;height:12px;line-height:12px; color:#cc0000;display:block;font-size:14px; text-align:center; position:absolute;top:4px;right:4px; cursor:pointer;}


    </style>
</head>
<body>
<div>
    <div class="wrapper wrapper-content ">
        <div class="col-sm-12">
            <div class="ibox">
                <div class="ibox-body">
                    <div class="form-group col-sm-4">
                        <label class="col-sm-2 control-label" style="margin-top:10px;width:11%;">网段</label>
                        <div class="col-sm-10">
                            <select name="rangeId"  id="rangeId" class="form-control">

                            </select>
                        </div>
                    </div>
                    <div class="form-group col-sm-2">
                        <button id="btnSearch" class="btn btn-success" onclick="search()">查询</button>
                        <!--<button id="btnReset" class="btn btn-danger" onclick="reSet()">重置</button>-->
                    </div>
                </div>
            </div>
        </div>
    </div>
    <ul class="item" id="ipShow">

    </ul>

    <div class="tip-info">
        <span class="ok"></span>可用
        <span class="online"></span>在线
        <span class="invalid"></span>无效
    </div>
</div>
<!--<div class="box">
    <p style="height:80px; line-height:80px; color:#aaa;font-size:18px; margin-bottom:5px;text-align:center;border:1px #0033FF solid;" class="item-net" tips="126666666666687">把鼠标移动框里来</p>
</div>-->

<div th:include="include :: footer"></div>
<script src="/js/utils/jquery.showTips.js"></script>
<script>

    //获取网段信息
    getScanIpRangeList();
    
    function search() {
        var rangeId = $("#rangeId").val();
        getVisualizationList(rangeId);
    }

    function getScanIpRangeList() {
        $.ajax({
            url : "/system/scanIpRange/getScanIpRangeList",
            type : "get",
            data : {},
            success : function(data) {
                var html = '';
                var firstRangeId;
                if(data != null && data != null) {
                    $.each(data, function(i){
                        if(i == 0 ) {
                            firstRangeId = this.id;
                        }
                        html += '<option value="'+this.id+'">'+ this.name1 + '(' + this.ipStart + '-' + this.ipEnd + ')</option>';
                    });
                }
                $("#rangeId").html(html);
                if(firstRangeId != null && firstRangeId != '') {
                    getVisualizationList(firstRangeId);
                }
            }
        });
    }

    function getVisualizationList(firstRangeId) {
        $.ajax({
            url: "/system/scanequip/getVisualizationList",
            type: "get",
            async: true,
            data: {"rangeid": firstRangeId},
            success: function (data) {
                var html = '';
                var startIp = data.startIp;
                var endIp = data.endIp;
                var scanequipList = data.scanequipList;
                var arr = new Array(endIp - startIp + 1);
                $.each(arr, function (i) {
                    var flag = false;
                    if(i == 0 || i == 255) {
                        html += '<li class="item-net" style="background-image:url(/img/scannet/baoliu.png)">';
                        html += '<div class="num" style="margin-top:-30px;">' + (i + startIp) + '</div>';
                        html += '</li>';
                    }else {
                        $.each(scanequipList, function (k) {
                            if (this.ipIndex == (i + startIp)) {
                                var showStr1 = '';
                                showStr1 += '<span>' + "IP地址：" + this.ipC + '</span></br>';
                                showStr1 += '<span>' + "MAC地址：" + this.macC + '</span></br>';
                                showStr1 += '<span>' + "操作系统：" + this.ostype + '</span></br>';
                                showStr1 += '<span>' + "设备类型详细信息：" + this.matchos + '</span>';
                                var ostypeIco = getIco(this.ostype,this.nflag1,this.availableState);
                                html += '<li class="item-net active" style="background-image:url('+ ostypeIco +')" tips="'+ showStr1 +'">';
                                html += '<div class="num" style="margin-top:-30px;">' + this.ipIndex + '</div>';
                                html += '</div>';
                                flag = true;
                            }
                        });
                        if (!flag) {
                            html += '<li class="item-net" style="background-image:url(/img/scannet/keyong.png)">';
                            html += '<div class="num" style="margin-top:-30px;">' + (i + startIp) + '</div>';
                            html += '</li>';
                        }
                    }
                });
                $("#ipShow").html(html);
            }
        });
    }

    function getIco(ostype,nflag1,availableState) {
        var ostypeIco = '';
        if(nflag1 == 1) {
            //在线
            if(ostype == 'windows') {
                ostypeIco = "/img/scannet/on_3.png"
            }else if(ostype == 'linux') {
                ostypeIco = "/img/scannet/on_2.png"
            }else if(ostype == 'mac') {
                ostypeIco = "/img/scannet/on_4.png"
            }else if(ostype == 'ios') {
                ostypeIco = "/img/scannet/on_6.png"
            }else if(ostype == 'android') {
                ostypeIco = "/img/scannet/on_5.png"
            }else if(ostype == 'switch') {
                ostypeIco = "/img/scannet/on_1.png"
            }else if(ostype == 'printer') {
                ostypeIco = "/img/scannet/on_7.png"
            }else if(ostype == 'router') {
                ostypeIco = "/img/scannet/on_router.png"
            }else if(ostype == 'balancer') {
                ostypeIco = "/img/scannet/on_balancer.png"
            }else if(ostype == 'environmental') {
                ostypeIco = "/img/scannet/on_environmental.png"
            }else if(ostype == 'firewall') {
                ostypeIco = "/img/scannet/on_firewall.png"
            }else if(ostype == 'modem') {
                ostypeIco = "/img/scannet/on_modem.png"
            }else if(ostype == 'nas') {
                ostypeIco = "/img/scannet/on_nas.png"
            }else if(ostype == 'vmware') {
                ostypeIco = "/img/scannet/on_vmware.png"
            }else if(ostype == 'unix') {
                ostypeIco = "/img/scannet/on_unix.png"
            }else if(ostype == 'camera') {
                ostypeIco = "/img/scannet/on_8.png"
            }else {
                ostypeIco = "/img/scannet/on_8.png"
            }
        }else if(nflag1 == 0) {
            //不在线
            if(ostype == 'windows') {
                ostypeIco = "/img/scannet/off_3.png"
            }else if(ostype == 'linux') {
                ostypeIco = "/img/scannet/off_2.png"
            }else if(ostype == 'mac') {
                ostypeIco = "/img/scannet/off_4.png"
            }else if(ostype == 'ios') {
                ostypeIco = "/img/scannet/off_6.png"
            }else if(ostype == 'android') {
                ostypeIco = "/img/scannet/off_5.png"
            }else if(ostype == 'switch') {
                ostypeIco = "/img/scannet/off_1.png"
            }else if(ostype == 'printer') {
                ostypeIco = "/img/scannet/off_7.png"
            }else if(ostype == 'router') {
                ostypeIco = "/img/scannet/off_router.png"
            }else if(ostype == 'balancer') {
                ostypeIco = "/img/scannet/off_balancer.png"
            }else if(ostype == 'environmental') {
                ostypeIco = "/img/scannet/off_environmental.png"
            }else if(ostype == 'firewall') {
                ostypeIco = "/img/scannet/off_firewall.png"
            }else if(ostype == 'modem') {
                ostypeIco = "/img/scannet/off_modem.png"
            }else if(ostype == 'nas') {
                ostypeIco = "/img/scannet/off_nas.png"
            }else if(ostype == 'vmware') {
                ostypeIco = "/img/scannet/off_vmware.png"
            }else if(ostype == 'unix') {
                ostypeIco = "/img/scannet/off_unix.png"
            }else if(ostype == 'camera') {
                ostypeIco = "/img/scannet/off_8.png"
            }else {
                ostypeIco = "/img/scannet/off_8.png"
            }
        }
        return ostypeIco;
    }

    $("body").on("mouseover",".active",function(){
        $(this).showTips({type:"html",alignTo:["follow"],trigger:"mouse",width:180});
    });

</script>
</body>
</html>